//
//  ConfirmPurchaseViewController.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/13.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "ConfirmPurchaseViewController.h"
#import "ConfirmPurchaseViewModel.h"
#import "CheckstandPurViewController.h"

@interface ConfirmPurchaseViewController ()<ConfirmPurDelegate>
@property (nonatomic,strong)ConfirmPurchaseViewModel * confirmViewModel;
@end

@implementation ConfirmPurchaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"确认求购";
    self.confirmViewModel = [[ConfirmPurchaseViewModel alloc] initWithViewToViewModel:self.groupedTableView theSuperView:self.view thePurchareModel:_pur_Model];
    self.confirmViewModel.con_Type = _pur_type;
    self.confirmViewModel.delegate = self;
}

#pragma mark -- set
-(void)setPur_Model:(PurchareModel *)pur_Model{
    _pur_Model = pur_Model;
    
}
#pragma mark -- ConfirmPurDelegate
-(void)comitePurOrder{
    NSArray * arr = @[@{@"productId":@"1004",
                        @"productName":@"四级螺纹钢",
                        @"materialId":@"4",
                        @"materialName":@"15CrMoG",
                        @"specificationsId":@"6",
                        @"specificationsName":@"Φ25",
                        @"factoryName":@"首唐宝生",
                        @"unit":@"吨",
                        @"weight":@25,
                        @"topPrice":@69}];
    NSDictionary * dic = @{@"userId":koString(self.userId),
                           @"type":@1,
                           @"quoteLimit":@0,
                           @"isSettlementTogether":@1,
                           @"payType":@1,
                           @"logisticsRequire":@1,
                           @"companyName":@"黑金时空",
                           @"contacts":@"杨礼军",
                           @"contactPhone":@"18301698947",
                           @"privacySetting":@1,
                           @"province":@"北京",
                           @"city":@"北京",
                           @"address":@"北京朝阳",
                           @"status":@1,@"productInfos":arr};
    NSMutableDictionary * parDic = [NSMutableDictionary dictionaryWithDictionary:dic];
    if (_pur_type == PurchaseType_Deposit) {//定金求购
        [parDic setObject:@100 forKey:@"depositAmount"];
    }
    [GLGWRequestTool POST:[NSString stringWithFormat:@"%@%@",kApiPrefix,kPublishPurchases] lodingView:nil lodingTextString:@"" isLoding:YES parameters:parDic success:^(id  _Nullable response) {
        
    } failure:^(NSError * _Nullable error) {
        
    }];
//    CheckstandPurViewController * checkstandVC = [CheckstandPurViewController new];
//    [self.navigationController pushViewController:checkstandVC animated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
